package kr.hkit.androidcomplete01;

import kr.hkit.androidcomplete01.ch04.Ch04Main;
import kr.hkit.androidcomplete01.ch05.Ch05Main;
import kr.hkit.androidcomplete01.ch06.Ch06Main;
import kr.hkit.androidcomplete01.ch06.work.Ch06workMain;
import kr.hkit.androidcomplete01.ch07.Ch07Main;
import kr.hkit.androidcomplete01.ch08.Ch08Main;
import kr.hkit.androidcomplete01.ch09.Ch09Main;
import kr.hkit.androidcomplete01.ch11.Ch11Main;
import kr.hkit.androidcomplete01_.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
	private String[] lists;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// setContentView(R.layout.activity_main);

		lists = getResources().getStringArray(R.array.main_list);// r array
																	// mainlist를
																	// 가져와서 참조하라

		/*
		 * for(String str:lists){ Log.d("lists", str); }
		 */

		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, lists);
		setListAdapter(adapter);

	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		/*
		 * String text ="View v = " + v.toString() + ": position =" + position +
		 * ", id =" + id; Toast.makeText(this, text,Toast.LENGTH_LONG).show();
		 */

		Intent intent = null;
		switch (position) {
		case 0:
			intent = new Intent(this, Ch06workMain.class);
			break;
		case 1:
			intent = new Intent(this, Ch04Main.class);// intent에 이 정보를 수행해달라
			break;
		case 2:
			intent = new Intent(this, Ch05Main.class);
			break;
		case 3:
			intent = new Intent(this, Ch06Main.class);
			break;
		case 4:
			intent = new Intent(this, Ch07Main.class);
			break;
		case 5:
			intent = new Intent(this, Ch08Main.class);
			break;
		case 6:
			intent = new Intent(this, Ch09Main.class);
			break;
		case 7:
			intent = new Intent(this, Ch11Main.class);
			break;	
		
			/*Toast.makeText(this, "즐거운 안드로이드", Toast.LENGTH_LONG).show();*/

		}
		startActivity(intent);
	}
}
